﻿<?php
include("mysql.php");

$image_first_id = $_POST['fid'];//first image to be shown
//get all the messages
$query = sprintf("SELECT id, tag, flag FROM images WHERE id >= '%s'",mysql_real_escape_string($image_first_id));
$result = mysql_query($query);

// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
	$message  = "Invalid query: " . mysql_error() . "\n";
	$message .= "Whole query: " . $query;
	mysql_close();
	die($message);
}

print(json_encode("FEEDBACK_START"));
$output = "";
while($row = mysql_fetch_array($result))
{
	$output = "FEEDBACK_IMG_NAME".$row['id'];
	print(json_encode($output));
	$output = "FEEDBACK_IMG_TAG".$row['tag'];
	print(json_encode($output));
	$output = "FEEDBACK_IMG_FLAG".$row['flag'];
	print(json_encode($output));
}

mysql_close();
?>